home *** CD-ROM | disk | FTP | other *** search
- Path: news.voicenet.com!news
- From: kobak@voicenet.com (Peter Kobak)
- Newsgroups: comp.lang.c++
- Subject: Re: Why can't I use this function prototype????
- Date: 11 Jan 1996 16:58:32 GMT
- Organization: Voicenet - Internet Access - (215)674-9290
- Message-ID: <4d3fjo$j5v@news.voicenet.com>
- NNTP-Posting-Host: philly218.voicenet.com
- X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
-
- In message <60ju5934@kbrady.ultranet.com> - Ken Brady <kbrady@ultranet.com>
- writes:
- :>/* pm_app.hpp */
- :>Class PmApplication {
- :> PmApplication();
- :> .... //member and method definitions here
- :>};
- :>
- :>PmApplication *Application(); //a typical function prototype??
- :>// other function prototypes here
- :>// end pm_app.hpp
- :>
- :>The compiler error is:
- :>myapp.cpp(53): Error! E043: (col 1) static function 'Application' has
- :>not been defined
- :>myapp.cpp(53): Note! N392: (col 1) 'PmApp * Application( void )'
- :>defined in: d:\c\lib\pm_app.hpp(55) (col 15)
-
- Your compiler is reporting a PmApp * Application() on the 'Note!', not a
- PmApplication * Application(). Is the return type name wrong in your .hpp
- file, despite what you posted as it's contents?
-
- :>I've tried implementing the global variable directly, i.e., defining
- :>the global variable 'PmApplication *App=NULL' in the header file.
- :>Then, the linker tells me that it has redefined App for every file that
- :>includes pm_app.hpp. How else can I implement a global variable?
-
- Declare the global in your header (.hpp) file:
- extern PmApplication * App;
-
- Define the global in your implementation (.cpp) file:
- PmApplication * App = NULL;
-
- This is just C stuff; no complication added because of C++.
-
- ================
- Peter Kobak
- kobak@voicenet.com
-
-
-